<extend name="Public/base"/>
<block name="body">
    <body ng-controller="ProCtrl"  ng-cloak class="ng-cloak" ng-init="editinit('{$BIN}')">
        <div class="main-title">
            <h2>{$title}</h2>
        </div>
        <form action="{:U('Material/editproduct')}" id="proform" method="post" enctype="multipart/form-data" class="form-horizontal">
            <div class="form-item">
                <label class="item-label">编号</label>
                <div class="controls">
                    <input type="text" class="text" name="BIN" ng-model="product.BIN"  readonly/>
                </div>
            </div>
            <div class="form-item">
                <label class="item-label">规格<span class="text-danger small">(例子：1箱/单位，20斤/箱，2个/装)</span></label>
                <div class="controls">
                    <input type="text" class="text" name="spec" ng-model="product.spec"  required/>
                </div>
            </div>
            <div class="form-item">
                <label class="item-label">规格编号<span class="text-danger small">(2位数字)</span></label>
                <div class="controls">
                    <input type="text" class="text" name="spec_no" ng-model="product.spec_no"  readonly/>
                </div>
            </div>
            <div ng-if="product.classify_no==2" >
                <div class="form-item">
                    <label class="item-label">人工费</label>
                    <div class="controls">
                        <input type="text" class="text" name="process_fee" ng-model="product.process_fee"  placeholder="加工费" required />
                    </div>
                </div>
                <div class="form-item">
                    <label class="item-label">快递费</label>
                    <div class="controls">
                        <input type="text" class="text" name="express_fee" ng-model="product.trans_fee" placeholder="快递费" required />
                    </div>
                </div>

                <div class="form-item">
                    <button type="button" ng-click="moreSubpro()" class="btn btn-primary">添加耗材</button>
                    <table class="table" style="width: 60%">
                            <tr ng-repeat="oldsub in oldsubpro">
                                <th>
                                    耗材[单价]
                                </th>
                                <td>
                                    {{oldsub.pname}}[{{oldsub.unitprice}}元]
                                    <input type="text" class="hide" name="subpro_id[]" value="{{oldsub.subpro_id}}">
                                </td>
                                <th>耗材数</th>
                                <td>
                                    {{oldsub.num}}
                                    <input type="text" class="hide" name="num[]" value="{{oldsub.num}}">
                                </td>
                                <th>包装类型</th>
                                <td>
                                    <span ng-if="oldsub.type==1">内包装</span>
                                    <span ng-if="oldsub.type==2">外包装</span>
                                    <input type="text" class="hide" name="type[]" value="{{oldsub.type}}">
                                </td>
                                <td>
                                    <a class="btn btn-primary" ng-click="removeOldSubpro($index)">-</a>
                                </td>
                            </tr>
                            <tr ng-repeat="sub in subpro">
                                <th>
                                    耗材[单价]
                                </th>
                                <td>
                                    <select select2 class="form-control input-3x" name="subpro_id[]">
                                        <option ng-repeat="s in subproductList" value="{{s.BIN}}">{{s.pname}}[{{s.unitprice}}元]</option>
                                    </select>
                                </td>
                                <th>耗材数</th>
                                <td>
                                    <input type="tel" name="num[]" class="form-control input-x">
                                </td>
                                <th>包装类型</th>
                                <td>
                                    <select name="type[]" class="form-control input-2x">
                                        <option value="1" selected>内包装</option>
                                        <option value="2">外包装</option>
                                    </select>
                                </td>
                                <td>
                                    <a class="btn btn-primary" ng-click="removeSubpro($index)">-</a>
                                </td>
                            </tr>
                    </table>
                </div>
            </div>
            <div class="form-item">
                <button class="btn submit-btn " id="submit" type="submit" target-form="form-horizontal">确 定</button>
                <button class="btn btn-return" onclick="javascript:history.back(-1);
                        return false;">返 回</button>
            </div>
        </form>
        </div>
    </body>
</block>

<block name="script">
    <script type="text/javascript" src="__JS__/material.js"></script>
    <script type="text/javascript">
        //导航高亮
        highlight_subnav('{:U('Material/productmanage')}');
    </script>
</block>
